<?php
/*
 * @Author: your name
 * @Date: 2021-09-21 16:46:35
 * @LastEditTime: 2021-12-15 14:42:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /nlog/app/Http/Controllers/AdminController/Login.php
 */

namespace App\Http\Controllers\admin_controller;

use Illuminate\Support\Facades\Request;
// use App\Models\admin_model\Store as StoreDb;
use App\Models\admin_model\FindShopSettngs as      FindShopSettngsDb     ;
use App\Http\Controllers\redis\RedisController as  redisDb;
class FindShopSettngs extends BaseController
{
    private $redisKey = 'find_shop_settings';
    public function settingSelOne(){
       if(redisDb::existSKey($this->redisKey)){
            $res =  redisDb::redishGetAll($this->redisKey);
       }else{
            $res = FindShopSettngsDb::selOne()[0];
            redisDb::hMset($this->redisKey,$res);
       } 
       return $this->create(200,'查询成功',$res);
    }

    public function settingsEdit(){
        if(Request::has('formData')){
               $formData = Request::input('formData');
               $formData['update_time'] =  date('Y-m-d H:i:s') ;
               $res = FindShopSettngsDb::updateOne($formData );
               if($res){
                  redisDb::hMset($this->redisKey,$formData);
               }
               return $this->create(200,'修改成功',$res);
        }
    }


    

}
